package falling 
{
	import org.flixel.*;
	/**
	 * ...
	 * @author morgan
	 */
	public class Sun extends SelectableObject
	{
		[Embed (source = "../../data/falling/2_sun.png")] private var img_sun:Class;
		
		public var initY:int = 0;
		public var initX:int = 0;
		
		public function Sun(x:int, y:int) 
		{
			super(x, y, null);
			loadGraphic(img_sun, true, false, 250, 250);
			initY = y;
			initX = x;
			baseScale = 0.95;
			selectRadius = width / 2;
		}
		
		override public function update():void 
		{
			super.update();
			
			color = FlxU.makeColorFromHSB(10 + FlxU.bound((initY - y / 10), 0, 9) * 3, 1, 1, 1);
			velocity.x = dx / dist * selectedValue * 20;
			velocity.y = dy / dist * selectedValue * 20;
			
			(FlxG.state as FallingState2).bg.color = FlxU.makeColorFromHSB(0, 0, FlxU.bound((initY - y / 10), 0, 9) * 0.06 + 0.35, 1);
			
			if (y < 150)
			{
				(FlxG.state as FallingState2).text2.clearingToWord = 99;
			}
			
			if (y < 120) { selectable = false; }
			if (selectedValue > 0.5)
			{
				frame = 0;
				angularVelocity = 10;
			} 
			else
			{
				frame = 1;
				angularVelocity = 0;
			}
		}
		
	}

}